package com.ihr360.sharedservice.calendar.dao;

import com.ihr360.sharedservice.calendar.dto.StatutoryVacation;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Date;
import java.util.List;

public interface StatutoryVacationDao extends JpaRepository<StatutoryVacation, Long> {

    @Query(value = "select a from StatutoryVacation a where DATE_FORMAT(vacationDate,'%Y%m')=DATE_FORMAT(:vacationDate,'%Y%m') and vacationCategory='SUPPLEMENTARY' ")
    List<StatutoryVacation> findByVacationDateAndVacationCategory(@Param("vacationDate") Date vacationDate);

    @Query(value = "select a from StatutoryVacation a where DATE_FORMAT(vacationDate,'%Y%m')=DATE_FORMAT(:vacationDate,'%Y%m') and vacationCategory in ('STATUTORY','ADJUSTMENT')")
    List<StatutoryVacation> findByVacationDateAndVacationCategoryIn(@Param("vacationDate") Date vacationDate);

    @Query(value = "select a from StatutoryVacation a where DATE_FORMAT(vacationDate,'%Y%m')=DATE_FORMAT(:vacationMonth,'%Y%m') and vacationCategory in ('STATUTORY','SUPPLEMENTARY')")
    List<StatutoryVacation> findStatutoryAndSupplementaryInMonth(@Param("vacationMonth") Date vacationMonth);

    List<StatutoryVacation> findByIsStatutoryHolidayAndVacationDateBetween(Boolean IsStatutoryHoliday, Date startTime, Date endTime);

}
